//
//  GetLunCommnetVModel.m
//  GuShiNews
//
//  Created by huachun on 2019/8/26.
//  Copyright © 2019 Jones. All rights reserved.
//

#import "GetLunCommnetVModel.h"
#import "HJonesNetting.h"
#import "LunCommentModel.h"
#import "HiJonesClass.h"
#import "HuaHereClass.h"

@implementation GetLunCommnetVModel

- (instancetype)init:(id)responseObject{
    if (self = [super init]) {
        
        [HJonesNetting JonesNetting_POST:responseObject
                                  andURL:Get_LuntanCommet
                              andtimeout:20.0
                                finished:^(NSError * _Nonnull error, NSDictionary * _Nonnull resultDict) {
                                    if (error) {
                                        [SVProgressHUD showErrorWithStatus:@"网络加载失败"];
                                        [self.delegate GetCommentSucces:0 array:nil page:[[responseObject objectForKey:@"page"] intValue]];
                                    }else{
                                        if ([[resultDict objectForKey:@"Code"] longLongValue]==1000) {
                                            
                                            NSMutableArray *hudonglist = [LunCommentModel mj_objectArrayWithKeyValuesArray:[resultDict objectForKey:@"LunCommetArray"]];
                                            
                                            [hudonglist enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                                                LunCommentModel *model = (LunCommentModel *)obj;
                                                model.type = 1;
                                                model.Height = [HuaHereClass size:model.lcomment_info font:[UIFont systemFontOfSize:16] width:RECRWITCH-30 height:10000].height+10;
                                                
                                            }];
                                            
                                            [self.delegate GetCommentSucces:1 array:hudonglist page:[[responseObject objectForKey:@"page"] intValue]];
                                        }else{
                                            [SVProgressHUD showErrorWithStatus:[resultDict objectForKey:@"Message"]];
                                            [self.delegate GetCommentSucces:0 array:nil page:[[responseObject objectForKey:@"page"] intValue]];
                                        }
                                    }
                                }
                              passmanger:^(NSURLSessionDataTask * _Nonnull manger) {
                                  
                              }
                             andprogress:^(NSProgress * _Nonnull CProgress) {
                                 
                             }];
        
    }
    return self;
}

@end
